import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import AccessView from '@/views/subView/AccessView.vue';
import GoodView from '@/views/subView/GoodView.vue';
import OrderView from '@/views/subView/OrderView.vue';
import SystemView from '@/views/subView/SystemView.vue';
import UserView from '@/views/subView/UserView.vue';
import UserInfoView from '@/views/subView/UserInfoView.vue';
import LoginView from '@/views/LoginView.vue';

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: to => {
        return { path: '/home' };
      }
    },
    {
      path: '/login',
      component: LoginView,
    },
    {
      path: '/home',
      component: HomeView,
      redirect: to => {
        return { path: '/home/user' };
      },
      children: [
        { path: 'access', component: AccessView },
        { path: 'good', component: GoodView },
        { path: 'user', component: UserView },
        { path: 'system', component: SystemView },
        { path: 'order', component: OrderView },
        { path: 'userinfo', component: UserInfoView, }
      ]
    },
  ],
})

export default router
